home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000231_icon-group-sender _Wed Nov 10 09:48:02 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id JAA29359
for icon-group-addresses; Wed, 10 Nov 1999 09:47:40 -0700 (MST)
Message-Id: <199911101647.JAA29359@baskerville.CS.Arizona.EDU>
X-Authentication-Warning: agate.berkeley.edu: news set sender to <news> using -f
From: Steve Wampler <swampler@noao.edu>
X-Newsgroups: comp.lang.icon
Subject: Re: List question
Date: Wed, 10 Nov 1999 08:44:04 -0700
X-Trace: noao.edu 942248646 36323 140.252.38.6 (10 Nov 1999 15:44:06 GMT)
X-Complaints-To: abuse@noao.edu
X-Accept-Language: en
To: icon-group@optima.CS.Arizona.EDU
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Anders Holtsberg wrote:
>
> Sorry folks. I just found the very recent discussion on
> this topic on Dejanews. But still: why not let
>
> mylist[5+:0] := anotherlist
>
> be a legal construct? I e the only change would be to
> let mylist[i:j] produce an l-value instead of an r-value,
> it would break no code at all, would it?
Correct, this change should have no impact on existing code.
> Is the implementation difficult? Are there filosophical
> or implementation problems? (I'm not nagging you guys: I can
> try to do the work if you think the change in semantics is OK).
I imagine others will disagree, but I'd like to see at least
an experimental version of Icon with this change in it. I
assume Anders means to differentiate list sectioning from
list subscripting and have any list section produce an l-value.
This change would bring us one step closer to providing list-scanning.
In fact, it would be possible to then produce a PDCO to experiment
with list-scanning.
However, it does require a non-trivial implementation - you'd have
to essentially reproduce internally the same types of operations
that people now have to use externally (though you could apply some
heuristics).
For example, implementing:
a[3:5] := [a,b,c,d]
would require producing a new list, as if the user had done:
a := a[1:3] ||| [a,b,c,d] ||| a[5:0]
(because list element storage is sequential in memory) thus adding
a single element in the middle of a list could have surprisingly
high runtime cost. It has this cost currently, but the fact that
the user has to explicitly code it means it's not a surprise...
On the other hand:
a[3:5] := []
could (possibly, depending on the desired semantics, see below) be done in
place on the original list, as could a[3:5] := [1] and a[3:5] := [1,2].
There are also a few major semantic issues to resolve. How close to the
behavior
of strings should list section assignment go? Strings and lists have some
fundamental differences that should be considered carefully. In particular,
note that, depending on the implementation, there could be a major difference
between
a[3:5] := [a,b,c,d]
and
a := a[1:3] ||| [a,b,c,d] ||| a[5:0]
(Suppose the assignment b := a is done prior to each of the above
statements. What should the value of b be?). So list section
assignment does mean that programmers would have to think very carefully
about how they are using lists. Of course, this is true currently; the
following code catches people sometimes...
a := [1,2,3,4]
b := a
a[2] := 5
Extending the above behavior to list sectioning is where the direct
implementation becomes complicated. You'd have to change how lists are
represented and provide "list qualifiers" much as strings are
implemented using string qualifiers.
Altering the semantics of list processing to provide even closer semantics
to string processing would be very difficult to implement and would
break existing code (because if you're going to "fix" list sectioning
this way, you'd want to also "fix" list element assignment as well).
I don't think I would be very keen on that drastic of a change.
--
Steve Wampler- SOLIS Project, National Solar Observatory
swampler@noao.edu